﻿(function () {
    var readPets = function (yourJSONObject) {
        var eventFile;
        Windows.Storage.KnownFolders.documentsLibrary.createFileAsync("pets.txt", Windows.Storage.CreationCollisionOption.openIfExists)
            .done(function (file) {
            eventFile = file;
            });
        Windows.Storage.FileIO.appendTextAsync(eventFile, JSON.stringify(yourJSONObject));
    }

    var writePets = function (yourJSONObject) {
        var eventFile;
        Windows.Storage.KnownFolders.documentsLibrary.createFileAsync("pets.txt", Windows.Storage.CreationCollisionOption.openIfExists)
            .done(function (file) {
                eventFile = file;
            });
        Windows.Storage.FileIO.appendTextAsync(eventFile, JSON.stringify(yourJSONObject));
    }

    var readVets = function (yourJSONObject) {
        var eventFile;
        Windows.Storage.KnownFolders.documentsLibrary.createFileAsync("vets.txt", Windows.Storage.CreationCollisionOption.openIfExists)
            .done(function (file) {
                eventFile = file;
            });
        Windows.Storage.FileIO.appendTextAsync(eventFile, JSON.stringify(yourJSONObject));
    }

    var writeVets = function (yourJSONObject) {
        var eventFile;
        Windows.Storage.KnownFolders.documentsLibrary.createFileAsync("vets.txt", Windows.Storage.CreationCollisionOption.openIfExists)
            .done(function (file) {
                eventFile = file;
            });
        Windows.Storage.FileIO.appendTextAsync(eventFile, JSON.stringify(yourJSONObject));
    }

    WinJS.Utilities.markSupportedForProcessing(readPets);
    WinJS.Utilities.markSupportedForProcessing(writePets);
    WinJS.Utilities.markSupportedForProcessing(readVets);
    WinJS.Utilities.markSupportedForProcessing(writeVets);

    WinJS.Namespace.define("LocalFolder", {
        readPets: readPets,
        writePets: writePets,
        readVets: readVets,
        writeVets: writeVets
    });
})();